home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2.0 - Programmer's Utilities Power Pack / Delphi 2.0 Programmer's Utilities Power Pack.iso / m_to_r / reporter / chrtrpt1.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-09-15  |  2.2 KB  |  85 lines

  1.  unit Chrtrpt1;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, Reports, StdCtrls, DB, DBTables, VBXCtrl, Chart2fx;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Button1: TButton;
  12.     Edit1: TEdit;
  13.     Edit2: TEdit;
  14.     Label1: TLabel;
  15.     Label2: TLabel;
  16.     ChartFX1: TChartFX;
  17.     procedure Button1Click(Sender: TObject);
  18.   private
  19.     { Private declarations }
  20.   public
  21.     { Public declarations }
  22.  
  23.     Procedure PrintHeader     ( HeaderBand  : tFixedReportBand;
  24.                                 var Status  : tBandStatus );
  25.  
  26.     Procedure PrintItem       ( DetailBand  : tFixedReportBand;
  27.                                 var Status  : tBandStatus );
  28.  
  29.   end;
  30.  
  31. var
  32.   Form1: TForm1;
  33.  
  34. implementation
  35.  
  36. {$R *.DFM}
  37.  
  38. procedure tForm1.PrintHeader (     HeaderBand : tFixedReportBand;
  39.                                var Status     : tBandStatus );
  40. Begin
  41.      With HeaderBand, Reporter Do
  42.      Begin
  43.           Canvas.Font.Size := 18;
  44.           Canvas.Font.Style := [fsBold];
  45.           BoxTextOut ( 'Chart FX Sample Report', ttaBandHCenter + ttaBandVCenter,
  46.                        btBox, 20, 10,
  47.                        stBottomRight, 20 );
  48.      End;
  49. End;
  50.  
  51. procedure tForm1.PrintItem   (     DetailBand : tFixedReportBand;
  52.                                var Status     : tBandStatus );
  53. Var
  54.    SaveX : Word;
  55. Begin
  56.      With DetailBand, Reporter Do
  57.      Begin
  58.           { Print out the chart, centered on the page.  Use the text in
  59.             Edit1 and Edit2 to set the width and height of the Chart on
  60.             the page.  This defaults to black/white printing.  If you
  61.             want to try color, change the last parameter to True }
  62.           PlaceChartFX ( ChartFX1, ttaBandHCenter + ttaBandVCenter,
  63.                          StrToFloat ( Edit1.Text ),
  64.                          StrToFloat ( Edit2.Text ),
  65.                          0, 0,
  66.                          False );
  67.      End;
  68.  
  69.      Status := bsDone;
  70. End;
  71.  
  72.  
  73. procedure TForm1.Button1Click(Sender: TObject);
  74. begin
  75.      { Set the Report's default unit to inches }
  76.      Reporter.PreferredUnit := puInches;
  77.  
  78.      Reporter.AddHeader ( PrintHeader );
  79.      Reporter.AddDetail ( Nil, PrintItem );
  80.  
  81.      Reporter.Run;
  82. end;
  83.  
  84. end.
  85.